package com.taobao.machinesystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taobao.machinesystem.entity.SysEquipment;
import com.taobao.machinesystem.entity.vo.SysEquipmentQueryVo;
import com.taobao.machinesystem.mapper.SysEquipmentMapper;
import com.taobao.machinesystem.service.SysEquipmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 设备表 服务实现类
 * </p>
 *
 * @author LiuJunCheng
 * @since 2022-04-22
 */
@Service
public class SysEquipmentServiceImpl extends ServiceImpl<SysEquipmentMapper, SysEquipment> implements SysEquipmentService {


    @Override
    public Page<SysEquipment> listSysEquipment(Integer currentPage, Integer size, SysEquipmentQueryVo sysEquipmentQueryVo) {
        Page<SysEquipment> sysCompanPage = new Page<>(currentPage, size);

        QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();

        if (!StringUtils.isEmpty(sysEquipmentQueryVo.getCode())) {
            queryWrapper.eq("CODE", sysEquipmentQueryVo.getCode());
        }
        if (!StringUtils.isEmpty(sysEquipmentQueryVo.getName())) {
            queryWrapper.likeLeft("NAME", sysEquipmentQueryVo.getName());
        }
        if (!StringUtils.isEmpty(sysEquipmentQueryVo.getType())) {
            queryWrapper.likeLeft("TYPE", sysEquipmentQueryVo.getType());
        }

        return baseMapper.selectPage(sysCompanPage, queryWrapper);
    }
}
